import { requireAuth } from "./auth-routes";

// 文章管理相关路由
export const postRoutes = {
  "/api/posts": {
    GET: requireAuth(() => new Response("List posts")),
    POST: requireAuth(async req => {
      console.log("📝 收到 POST 请求");    
      try {
        const body = await req.json() as any;
        console.log("📦 请求体:", body);
        
        const result = { created: true, ...body };
        console.log("✅ 处理结果:", result);
        
        return Response.json(result);
      } catch (error) {
        console.error("❌ 解析 JSON 失败:", error);
        return new Response("Invalid JSON", { status: 400 });
      }
    }),
  }
};
